<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@   page   contentType="text/html;charset=utf-8" language="java"   buffer="none"   %> 
<html>
<head>
<title>南雄同乡会信息管理系统</title>
</head>
<style>
  	.demo{
  		width:auto;
  		height:20px;
  		background:#ccddff;
  		border:1px solid #000;
  		position:absolute;
  		left:140px;
  		padding:12px 20px;
  	}
  </style>
	<link rel="stylesheet" type="text/css" href="CSS/style.css">
	<script type="text/javascript" src="JS/jquery-1.11.1.js"></script>
<body>
	<div id="demo" class="demo"></div>
	<div id="maindiv">
		<div id="topnews" class="left1">
			<div class="title">最新帖子</div>			
		</div>
		<div class="right1" id="topIndiAct">
			<div class="title">个人活动</div>	
		</div>
		<div class="left1" id="topAct">
			<div class="title">组织活动</div>		
		</div>
		<div class="right1" id="architecture">
			<div class="title">组织架构</div>
			<div class="titlelist">会长：王明贤</div>
			<div class="titlelist">秘书长：李松松</div>
			<div class="titlelist">组织委员：叶芳芳</div>
			<div class="titlelist">外联委员：陈志棋</div>
			<div class="titlelist">文娱委员：张毅</div>
			<div class="titlelist">生活委员：卢贤欢</div>
			<div class="titlelist">宣传委员：谢立锋</div>
		</div>
	</div>	
</body>
<script>


	
	   function animateMade(element,speed){
		   if($(".demo").css("left")=="840px"){
			   $(".demo").css("left","140px");
		   }
		   element.animate({"left":"+=700px","top":"+=0px"},speed,"swing",function(){animateMade($("#demo"),12000);});
	   }
	   
	   animateMade($("#demo"),12000); 	   



		//获取最新的10条帖子
		$.ajax({
			url:'<%=basePath%>getTopNewsAction',
			type:'post',
			typeData:'json',
			timeout:1000,
			beforeSend:beforeFunc,
			error:errorFunc,
			success:getTopNews
		});
		function beforeFunc(){}
		function errorFunc(){}
		function getTopNews(datas){
			var json = eval(datas);
			$.each(json,function(index){
				$("#topnews").html($("#topnews").html()+"<div class='titlelist'>"+(index+1)+"、<a href='<%=basePath%>news/news.jsp?newsId="+json[index].newsId+"'>"+json[index].newsTheme+"</div>");
			});
		}
		//获取最新的10条个人活动
		$.ajax({
			url:'<%=basePath%>getTopIndiActAction',
			type:'post',
			typeData:'json',
			timeout:1000,
			beforeSend:beforeFunc,
			error:errorFunc,
			success:function(datas){
				var json = eval(datas);
				$.each(json,function(index){
					$("#topIndiAct").html($("#topIndiAct").html()+"<div class='titlelist'>"+(index+1)+"、<a href='<%=basePath%>indiAct/indiActivity.jsp?individualId="+json[index].individualId+"'>"+json[index].individualTheme+"</div>");
				});},
		});
		
		//获取最新的5条组织活动
		$.ajax({
			url:'<%=basePath%>getTopActAction',
			type:'post',
			typeData:'json',
			timeout:1000,
			beforeSend:beforeFunc,
			error:errorFunc,
			success:function(datas){	
				var json = eval(datas);
				$.each(json,function(index){
					$("#topAct").html($("#topAct").html()+"<div class='titlelist'>"+(index+1)+"、<a href='<%=basePath%>activities/showActivity.jsp?actId="+json[index].activityId+"'>"+json[index].activityTheme+"</div>");
				});},
		});
	
		//获取当前月份的计划活动
		$.ajax({
			url:'<%=basePath%>getCurrentMonthPlanActAction',
			type:'get',
			typeData:'json',
			timeout:1000,
			beforeSend:beforeFunc,
			error:errorFunc,
			success:function(datas){
				//alert(datas);
				var json = eval(datas);
				$.each(json,function(index){
					//如果当月无活动，返回
					if(json.length<1){
						$("#demo").remove();
						return;
					}
					$("#demo").html($("#demo").html()+
							"<span>本月计划活动：<<"+json[index].planTheme+">>&nbsp;即将开始"+
							"</span><button onclick='attendPlan("+json[index].planId+")'>参与出谋划策</button></div>");
				});
				},
		});
		
		function attendPlan(planId){
			window.location.href="<%=basePath%>activities/advise.jsp?planId="+planId;
		}
</script>
</html>